<?php
/*
----------------------------------------------------------------------------------------------------------------
HTTP Simple Queue Service - httpsqs client class for PHP v1.2

Author: Zhang Yan (http://blog.s135.com), E-mail: net@s135.com
This is free software, and you are welcome to modify and redistribute it under the New BSD License
----------------------------------------------------------------------------------------------------------------
Useage:
<?php
......
include_once("httpsqs_client.php");
$httpsqs = new httpsqs;

//http connect without Keep-Alive
$result = $httpsqs->put($host, $port, $charset, $name, $data); //1. PUT text message into a queue. If PUT successful, return boolean: true. If an error occurs, return boolean: false. If queue full, return text: HTTPSQS_PUT_END
$result = $httpsqs->get($host, $port, $charset, $name); //2. GET text message from a queue. Return the queue contents. If there is no unread queue message, return text: HTTPSQS_GET_END
$result = $httpsqs->gets($host, $port, $charset, $name); //3. GET text message and pos from a queue. Return example: array("pos" => 7, "data" => "text message"). If there is no unread queue message, return: array("pos" => 0, "data" => "HTTPSQS_GET_END")
$result = $httpsqs->status($host, $port, $charset, $name); //4. View queue status
$result = $httpsqs->view($host, $port, $charset, $name, $pos); //5. View the contents of the specified queue pos (id). Return the contents of the specified queue pos.
$result = $httpsqs->reset($host, $port, $charset, $name); //6. Reset the queue. If reset successful, return boolean: true. If an error occurs, return boolean: false
$result = $httpsqs->maxqueue($host, $port, $charset, $name, $num); //7. Change the maximum queue length of per-queue. If change the maximum queue length successful, return boolean: true. If  it be cancelled, return boolean: false

//http pconnect with Keep-Alive (Very fast in PHP FastCGI mode & Command line mode)
$result = $httpsqs->pput($host, $port, $charset, $name, $data); //1. PUT text message into a queue. If PUT successful, return boolean: true. If an error occurs, return boolean: false.  If queue full, return text: HTTPSQS_PUT_END
$result = $httpsqs->pget($host, $port, $charset, $name); //2. GET text message from a queue. Return the queue contents. If there is no unread queue message, return text: HTTPSQS_GET_END
$result = $httpsqs->pgets($host, $port, $charset, $name); //3. GET text message and pos from a queue. Return example: array("pos" => 7, "data" => "text message"). If there is no unread queue message, return: array("pos" => 0, "data" => "HTTPSQS_GET_END")
$result = $httpsqs->pstatus($host, $port, $charset, $name); //4. View queue status
$result = $httpsqs->pview($host, $port, $charset, $name, $pos); //5. View the contents of the specified queue pos (id). Return the contents of the specified queue pos.
$result = $httpsqs->preset($host, $port, $charset, $name); //6. Reset the queue. If reset successful, return boolean: true. If an error occurs, return boolean: false
$result = $httpsqs->pmaxqueue($host, $port, $charset, $name, $num); //7. Change the maximum queue length of per-queue. If change the maximum queue length successful, return boolean: true. If  it be cancelled, return boolean: false
?>
----------------------------------------------------------------------------------------------------------------
*/
include_once("httpsqs_client.php");
$host = '192.168.199.10';
$port = '1218';
$charset = 'utf-8';
$httpsqs = new httpsqs($host,$port,'',$charset);

$name = 'test';
$data = [
    'g' => 'gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg',
    'h' => 'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh',
    'i' => 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii'
];

$data = json_encode($data);

$result = $httpsqs->put($name, $data);
$result = $httpsqs->get($name);